# This file is part of BlackArch Linux ( https://www.blackarch.org/ ).
# See COPYING for license details.

pkgname=nili
pkgver=39.285220a
pkgrel=10
pkgdesc='Tool for Network Scan, Man in the Middle, Protocol Reverse Engineering and Fuzzing.'
groups=('blackarch' 'blackarch-scanner' 'blackarch-reversing'
        'blackarch-fuzzer')
arch=('any')
url='https://github.com/niloofarkheirkhah/nili'
license=('GPL3')
depends=('python' 'python-argparse' 'python-scapy' 'netzob')
makedepends=('git' 'python-setuptools')
source=("git+https://github.com/niloofarkheirkhah/$pkgname.git")
sha512sums=('SKIP')

pkgver() {
  cd $pkgname

  echo $(git rev-list --count HEAD).$(git rev-parse --short HEAD)
}

build() {
  cd $pkgname

  python setup.py build
}

package() {
  cd $pkgname

  install -dm 755 "$pkgdir/usr/bin"
  install -dm 755 "$pkgdir/usr/share/$pkgname"

  python setup.py install --root="$pkgdir" --prefix=/usr -O1 --skip-build

  install -Dm 644 -t "$pkgdir/usr/share/doc/$pkgname/" README.md
  install -Dm 644 LICENSE "$pkgdir/usr/share/licenses/$pkgname/LICENSE"

  rm README.md LICENSE

  cp -a * "$pkgdir/usr/share/$pkgname/"

  cat > "$pkgdir/usr/bin/$pkgname" << EOF
#!/bin/sh
cd /usr/share/$pkgname/$pkgname
exec python3 __main__.py "\$@"
EOF

  chmod +x "$pkgdir/usr/bin/$pkgname"
}

